import jsxToAst from './jsxToAst.js';
import extractReactComponents from './extractReactComponents.js';
import jsdocToJson from './jsdocToJson.js';
import formatJSDocComments from './formatJSDocComments.js';

/**
 * 生成React组件文档
 * @param {string} jsxCode - React组件代码
 * @returns {Object} - 包含组件文档信息的对象
 */
export default function generateComponentDocs(jsxCode) {
  const ast = jsxToAst(jsxCode);
  const components = extractReactComponents(ast);
  
  const docs = {};
  for (const [name, jsdoc] of components) {
    const formattedJsdoc = formatJSDocComments(jsdoc);
    docs[name] = jsdocToJson(formattedJsdoc);
  }
  
  return docs;
}